home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE21 / CONSTRUC / PLUGIN.DPR < prev    next >
Encoding:
Text File  |  1997-04-09  |  2.8 KB  |  118 lines

  1. library plugin;
  2. uses
  3. {$IFDEF WIN32}{$H+}
  4.   ShareMem,
  5. {$ENDIF}
  6.   Wizard, ExptIntf, ToolIntf, VirtIntf, Forms, Dialogs, SysUtils;
  7.  
  8.  
  9.   procedure HandleException;
  10.   begin
  11.     if Assigned(ToolServices) then
  12.       ToolServices.RaiseException(ReleaseException)
  13.   end {HandleException};
  14.  
  15.  
  16. Type
  17.   TPlugInExpert = class(TIExpert)
  18.   public
  19.     { Expert Style }
  20.     function GetStyle: TExpertStyle; override;
  21.     { Expert Strings }
  22.     function GetIDString: String; override;
  23.     function GetName: String; override;
  24.   {$IFDEF WIN32}
  25.     function GetAuthor: String; override;
  26.   {$ENDIF}
  27.     function GetMenuText: String; override;
  28.     function GetState: TExpertState; override;
  29.     { Launch the Expert }
  30.     procedure Execute; override;
  31.   end {TPlugInExpert};
  32.  
  33.  
  34.   function TPlugInExpert.GetStyle: TExpertStyle;
  35.   begin
  36.     Result := esStandard
  37.   end {GetStyle};
  38.  
  39.   function TPlugInExpert.GetIDString: String;
  40.   begin
  41.     Result := 'DrBob.TPlugInExpert'
  42.   end {GetIDString};
  43.  
  44.   function TPlugInExpert.GetName: String;
  45.   begin
  46.     Result := 'Dr.Bob''s PlugIn Wizard Expert'
  47.   end {GetName};
  48.  
  49. {$IFDEF WIN32}
  50.   function TPlugInExpert.GetAuthor: String;
  51.   begin
  52.     Result := 'Dr.Bob'
  53.   end {GetAuthor};
  54. {$ENDIF}
  55.  
  56.   function TPlugInExpert.GetMenuText: String;
  57.   begin
  58.     Result := 'No Project Wizard Available';
  59.     if Assigned(ToolServices) then with ToolServices do
  60.     try
  61.       if (GetUnitCount > 0) and
  62.          (GetFormCount > 0) and
  63.          (Length(GetProjectName) > 0) then
  64.         Result := '&Project Wizard for ' +
  65.                     ExtractFileName(GetProjectName) + '...'
  66.     except
  67.       HandleException
  68.     end
  69.   end {GetMenuText};
  70.  
  71.   function TPlugInExpert.GetState: TExpertState;
  72.   begin
  73.     Result := [];
  74.     if Assigned(ToolServices) then with ToolServices do
  75.     try
  76.       if (GetUnitCount > 0) and
  77.          (GetFormCount > 0) and
  78.          (Length(GetProjectName) > 0) then Result := [esEnabled]
  79.     except
  80.       HandleException
  81.     end
  82.   end {GetState};
  83.  
  84.   procedure TPlugInExpert.Execute;
  85.   begin
  86.     if Assigned(ToolServices) then with ToolServices do
  87.     try
  88.       with TWizardForm.Create(nil) do
  89.       try
  90.         ShowModal
  91.       finally
  92.         Free
  93.       end
  94.     except
  95.       HandleException
  96.     end
  97.   end {Execute};
  98.  
  99.  
  100.   function InitExpert(Delphi: TIToolServices;
  101.                       RegisterProc: TExpertRegisterProc;
  102.                   var Terminate: TExpertTerminateProc): Boolean;
  103.   {$IFDEF WIN32} stdcall; {$ELSE} export; {$ENDIF}
  104.   begin
  105.     ExptIntf.ToolServices := Delphi; { Save! }
  106.     if ToolServices <> nil then
  107.       Application.Handle := ToolServices.GetParentHandle;
  108.     Result := RegisterProc(TPlugInExpert.Create)
  109.   end {InitExpert};
  110.  
  111.  
  112. exports
  113.   InitExpert name ExpertEntryPoint resident,
  114.   InitExpert name 'INITEXPERT0017'; { for Delphi 3 }
  115.  
  116. begin
  117. end.
  118.